clear all; close all; clc;


Fd = 40e3; % [Hz]
Td = 1/Fd;
Tmod = 0.3;
t = 0:Td:Tmod;
ft = 500+100*rand(1,1);
S = cos(2*pi*ft*t);


Swin = S.* parzenwin(length(t))';
% figure;
% plot( t, S )


Sfwin = fft(Swin);
Sf = fft(S);


T = Tmod + Td;
f = 0:1/T:(1/Td - 1/T);


[Y, I] = max(abs(Sf));


fn = f(I);


plot(f,abs(Sf),f,abs(Sfwin))
xlim([400 700]);
legend('No window','Window')
xlabel('f, Hz')
ylabel('|S(f)|,|S_{win}(f)|')
fn
ft